home *** CD-ROM | disk | FTP | other *** search
/ HyperLib 1997 Winter - Disc 1 / HYPERLIB-1997-Winter-CD1.ISO.7z / HYPERLIB-1997-Winter-CD1.ISO / オンラインウェア / UTIL / Alpha 6.5.sit / Tcl / UserCode / date.tcl < prev    next >
Text File  |  1996-08-15  |  2KB  |  82 lines

  1. # FILE: date.tcl
  2. #
  3. # LAST UPDATE: 01/06/93 4:42:28 AM
  4. #
  5. # This file contains the following TCL procedure(s):
  6. #
  7. #     date -- returns current date
  8. #
  9. #    This proc returns current formatted date
  10. #
  11. #    Optional argument: short, long, abbrev, time, weekday, month, day, year
  12. #
  13. #     This proc is useful with electricAlias definitions (ie. 、ヌdateネ).
  14. #
  15. #    To use, simply source this file place it in the a folder with the
  16. #    name $HOME:Tcl:Usercode: and invoke it implicitly via the "unknown proc".
  17. #
  18. # SEE ALSO unknown.tcl, electricAlias.tcl
  19.  
  20. # COPYRIGHT:
  21. #
  22. #    Copyright ゥ 1992,1993 by David C. Black
  23. #    All rights reserved.
  24. #
  25. #    Redistribution and use in source and binary forms are permitted
  26. #    provided that the above copyright notice and this paragraph are
  27. #    duplicated in all such forms and that any documentation,
  28. #    advertising materials, and other materials related to such
  29. #    distribution and use acknowledge that the software was developed
  30. #    by David C. Black.
  31. #
  32. #    THIS SOFTWARE IS PROVIDED "AS IS" AND WITHOUT ANY EXPRESS OR
  33. #    IMPLIED WARRANTIES, INCLUDING, WITHOUT LIMITATION, THE IMPLIED
  34. #    WARRANTIES OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR PURPOSE.
  35. #
  36. ################################################################################
  37.  
  38. # AUTHOR
  39. #
  40. #    David C. Black
  41. #    Internet: black@mpd.tandem.com (preferred)
  42. #    GEnie:    D.C.Black
  43. #    USnail:   6217 John Chisum Lane, Austin, TX 78749
  44. #
  45. ################################################################################
  46.  
  47. # HISTORY
  48. #                  
  49. # modified who rev reason
  50. # -------- --- --- ------
  51. # 01/06/93 DCB 1.0 Original
  52.  
  53. proc date {{fmt ""}} {
  54.     case "$fmt" {
  55.     {} {
  56.         set str [mtime [now]]
  57.         regsub { [0-9][0-9]?:[0-9][0-9]?:[0-9][0-9]?} $str "" str
  58.     }
  59.     {long short abbrev} {
  60.         set str [mtime [now] $fmt]
  61.         regsub { [0-9][0-9]?:[0-9][0-9]?:[0-9][0-9]? [AP]M} $str "" str
  62.     }
  63.     {weekday month day year} {
  64.         set str [mtime [now] long]
  65.         regexp {([A-Z][a-z]+), ([A-Z][a-z]+) ([0-9]+), ([0-9]+)} $str all weekday month day year
  66.         case "$fmt" {
  67.         {weekday} {set str $weekday}
  68.         {month}   {set str $month}
  69.         {day}     {set str $day}
  70.         {year}    {set str $year}
  71.         }
  72.     }
  73.     {time} {
  74.         regexp {[0-9][0-9]?:[0-9][0-9]:[0-9][0-9] [AP]M} [mtime [now] short] str
  75.     }
  76.     }
  77.     return "$str"
  78. }
  79. #endproc date
  80. ################################################################################
  81.  
  82.